/* implementation of demo */
#include "function_layer/Display.h"
#include "function_layer/CountDisplay.h"
#include "implement_layer/StringDisplayImpl.h"

/* Function Layer */
void FuncLayer::Display::open()
{
    pimpl->rawOpen();
}

void FuncLayer::Display::print()
{
    pimpl->rawPrint();
}

void FuncLayer::Display::close()
{
    pimpl->rawClose();
}

void FuncLayer::Display::display()
{
    open();
    print();
    close();
}


void FuncLayer::CountDisplay::multiDisplay(unsigned int times)
{
    open();
    for(int i = 0; i < times; i++)
        print();
    close();
}


/* Implementation layer */
void ImplLayer::StringDisplayImpl::rawOpen()
{
    printLine();
}
void ImplLayer::StringDisplayImpl::rawPrint()
{
    std::cout << "|" << str << "|" << std::endl;
}
void ImplLayer::StringDisplayImpl::rawClose()
{
    printLine();
}
